package com.dabao.controller.admin;

import com.dabao.controller.BaseController;
import com.dabao.util.CacheUtils;
import com.dabao.util.CookieUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by card on 16/4/22.
 */
@Controller
@RequestMapping(value = "/admin")
public class LogoutController extends BaseController{

    @RequestMapping("/logout")
    public String logout(HttpServletRequest request, HttpServletResponse response) {
        String username = CookieUtils.getUsername(request);
        CookieUtils.logout(response);
        CacheUtils.remove(username);
        CacheUtils.remove(username + "_menus");
        CacheUtils.remove(username + "_permissions");
        return redirect("/admin/index");
    }
}
